package com.isoft.sjhy.util;

import java.time.LocalDate;
import java.util.Calendar;
import java.util.Date;

/**
 * 2 * @Author: 郭邈
 * 3 * @Date: 2021/6/24 10:13
 * 4 * @ClassName:sjhy
 * 4 * @PACKAGE_NAME:com.isoft.sjhy.util
 */
public class DateTimeCom {
    public static long getBetweenDay(Date jzsj) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(jzsj);					//放入Date类型数据
        int year=calendar.get(Calendar.YEAR);					//获取年份
        int month=calendar.get(Calendar.MONTH);					//获取月份
        int day=calendar.get(Calendar.DATE);
        LocalDate start = LocalDate.of(year,month,day);
        LocalDate now = LocalDate.now();
        return getBetweenDay(start, now);
    }

    public static long getBetweenDay(LocalDate start, LocalDate end) {
        return end.toEpochDay() - start.toEpochDay();
    }

    public static int getBetweenDay(Date date1,Date date2)
    {
        int days = (int) ((date2.getTime() - date1.getTime()) / (1000*3600*24));
        return days;
    }

}

